
// compoents/visitSchoolPanel2/visitSchoolPane2.js
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    timeArray: {
      type: Object,
      value: [{
        id:1,
        time: '1小时',
        routeType: '号路'
      }]
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    timeArrayData: {
      type: Object,
      value: [{
        id:1,
        time: '1小时',
        routeType: '号路',
        fontWeight:'',
        color:''
      }]
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    selectRoute(e) {
      // console.log(e.currentTarget.dataset.info)
      const newList = this.properties.timeArray.map((item, i) => {
        return {
          id:item.id,
         time:item.time,
         routeType:item.routeType,
         color:item.time == e.currentTarget.dataset.info.time ? '#951816':'#242424',
         fontWeight:item.time == e.currentTarget.dataset.info.time ? 'bold':'normal'
        };
      });
      this.setData({
        timeArrayData: newList
      });
      this.triggerEvent('sync',{value:e.currentTarget.dataset.info.routeType})
      // console.log(this.data.timeArrayData)
    },
    
  },
  attached() {
    //组价挂载时   可以考虑从外部传个参数来选择渲染哪一个
    this.setData({
      timeArrayData:this.properties.timeArray
    })
  }
})